home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / init.d / fuse < prev    next >
Encoding:
Text File  |  2010-09-18  |  2.8 KB  |  113 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          fuse
  4. # Required-Start:    $remote_fs
  5. # Required-Stop:     $remote_fs
  6. # Default-Start:     S
  7. # Default-Stop:      0 6
  8. # Short-Description: Filesystem in userspace
  9. # Description:       This file load all what's needed to make fuse work fine
  10. ### END INIT INFO
  11.  
  12. # Author: Adam C├⌐cile (Le_Vert) <gandalf@le-vert.net>
  13.  
  14. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  15. DESC="filesystem in userspace"
  16. NAME=fuse
  17. SCRIPTNAME=/etc/init.d/$NAME
  18. MOUNTPOINT=/sys/fs/fuse/connections
  19.  
  20. # Gracefully exit if the package has been removed.
  21. test -x `which fusermount` || exit 0
  22.  
  23. # Load the VERBOSE setting and other rcS variables
  24. . /lib/init/vars.sh
  25.  
  26. # Define LSB log_* functions.
  27. . /lib/lsb/init-functions
  28.  
  29. do_start()
  30. {
  31.     # Return
  32.     #   0 if fuse has been started
  33.     #   1 if kernel module load failed
  34.     #   2 if fusectl filesystem mount failed
  35.         if ! grep -qw fuse /proc/filesystems; then
  36.                 modprobe fuse >/dev/null 2>&1 || return 1
  37.         # Dirty fix for #473545
  38.         #
  39.         # In fact the postinst script will fail at the first
  40.         # install if you don't have fuse kernel module loaded.
  41.         # (module not loaded -> no /dev/fuse -> postinst noop)
  42.         # Let's fix it their for now, if someone has a better idea
  43.         # please re-open #473545.
  44.         test -e /dev/fuse && chgrp fuse /dev/fuse
  45.         fi
  46.         if grep -qw fusectl /proc/filesystems && \
  47.            ! grep -qw $MOUNTPOINT /proc/mounts; then
  48.                 mount -t fusectl fusectl $MOUNTPOINT >/dev/null 2>&1 || \
  49.                         return 2
  50.         fi
  51. }
  52.  
  53. do_stop()
  54. {
  55.     # Return
  56.     #   0 if fuse has been stopped
  57.     #   1 if fusectl filesystem umount failed
  58.     #   2 if kernel module unload failed
  59.     #   3 if fuse filesystems unmount failed
  60.         if grep -qw $MOUNTPOINT /proc/mounts; then
  61.                 umount $MOUNTPOINT >/dev/null 2>&1 || \
  62.                         return 1
  63.         fi
  64.         umount -at fuseblk >/dev/null 2>&1 || return 3
  65.         umount -at fuse >/dev/null 2>&1 || return 3
  66.         if grep -qw "^fuse" /proc/modules; then
  67.                 rmmod fuse >/dev/null 2>&1 || return 2
  68.         fi
  69. }
  70.  
  71. case "$1" in
  72.   start)
  73.     [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  74.     do_start
  75.     case "$?" in
  76.         0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  77.         2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  78.     esac
  79.     ;;
  80.   stop)
  81.     [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  82.     do_stop
  83.     case "$?" in
  84.         0|2|3) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  85.         1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  86.     esac
  87.     ;;
  88.   restart|force-reload)
  89.     log_daemon_msg "Restarting $DESC" "$NAME"
  90.     do_stop
  91.     case "$?" in
  92.       0|2|3)
  93.         do_start
  94.         case "$?" in
  95.             0) log_end_msg 0 ;;
  96.             1) log_end_msg 1 ;; # Old process is still running
  97.             *) log_end_msg 1 ;; # Failed to start
  98.         esac
  99.         ;;
  100.       *)
  101.           # Failed to stop
  102.         log_end_msg 1
  103.         ;;
  104.     esac
  105.     ;;
  106.   *)
  107.     echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  108.     exit 3
  109.     ;;
  110. esac
  111.  
  112. :
  113.